package com.prj.ufdm.cloud.svr.gateway.config;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.prj.ufdm.cloud.svr.gateway.bpo.SysFunctionBPO;
import com.prj.ufdm.cloud.svr.gateway.constant.WebSecurityConstants;
import com.prj.ufdm.cloud.svr.gateway.model.SysFunction;

/**
 * 启动接收数据平台通知接收接口
 * @author Administrator
 */
@Component
public class StartupConfig implements CommandLineRunner {

	@Autowired
	private SysFunctionBPO sysFunctionBPO;
	@Autowired
	private RedisService redisService;
	
	@Override
	public void run(String... args) throws Exception {
		try {
			if(WebSecurityConstants.REDIS_ENABLED) {
				List<SysFunction> listSysFunction = sysFunctionBPO.doGetFunctionList();
				redisService.set(WebSecurityConstants.REDIS_MAP_KEY_FUNCTION_METADATASOURCE, listSysFunction);
			}
		}catch(Exception er) {
			System.out.println("\n 初始化受保护资源...，出现异常：");
			er.printStackTrace();
		}
	}

}
